package cn.edu.scau.cmi;
import java.sql.Connection;

import java.sql.DriverManager; 
import java.sql.PreparedStatement; 
import java.sql.SQLException; 
import java.sql.Statement; 

public class client {



public static void main (String[] args) throws ClassNotFoundException, SQLException{
	Class.forName("com.mysql.jdbc.Driver");
	String url = "jdbc:mysql://localhost:3306/jsp";
	String username = "root";
	String password = "root";
	Connection conn = DriverManager.getConnection(url,username,password);
	
	String insertSql = "insert into tb_student(age,sex,name,id) values('21','8','zhangsan','1')";
	
	Statement ps = conn.prepareStatement(insertSql);
	
	String insertSqlDynamic = "insert into tb_student(age,sex,name,id) values(?,?,?,?)";
	PreparedStatement dps = conn.prepareStatement(insertSqlDynamic);
	dps.setInt(1,1);
	dps.setInt(2,4);
	dps.setString(3,"zhangxiaohua");
	dps.setInt(4,3);


	dps.execute();
	System.out.println("ok");
	
}
}